package com.chucang.shucang.common.oss.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author flitsneak
 * @email flitsneak@gmail.com
 * @date 2022/10/3 0:23
 * @description
 */
@Data
@AutoConfiguration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {
    private String accessKey;
    private String secretKey;
    private String endPoint;
    private int port;
    private String bucketName;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(endPoint, port, false)
                .credentials(accessKey, secretKey)
                .build();
    }
}
